<!DOCTYPE html>
<html>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='ie=edge'>
    <title>Document</title>
</head>

<body>
    <div id='app'>
        <p>{{msg}}</p>
        <input v-model="msg">
    </div>
    <script src='./vue.js'></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: ''
            },
            // watch是Vue实例选项
            // watch作用: 监听data中属性的变化,每当属性变化,就会获取属性的值(新值/旧值)
            watch: {
                // data中被监听的属性:function(新值,旧值){}
                msg: function(newVal, oldVal) {
                    console.log(`新值是${newVal},旧值是${oldVal}`);
                }
            },
            methods: {

            }
        });
    </script>
</body>

</html>